package com.masterclient.app.modules.firstpager.fragments.contract;

import com.eoner.baselib.presenter.ThrowableConsumer;
import com.eoner.managerlibrary.netsign.NetEnvManager;
import com.masterclient.app.httpservice.RetrofitUtil;
import com.eoner.baselibrary.bean.firstpager.NewProductDiscountBean;

import io.reactivex.Observable;
import io.reactivex.annotations.NonNull;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;

/**
* Created by TMVPHelper on 2017/08/15
*/
public class NewGoodsSubPresenter extends NewGoodsSubContract.Presenter{

    @Override
    public void getNewProductDiscoutList(String event_id) {
        Observable<NewProductDiscountBean> observable = RetrofitUtil.getInstance().getNewGoodDiscountList(NetEnvManager.BASE_SURL+"1/new_product/products/event_id_"+event_id+".html");

        Disposable disposable = toSubscribe(observable, new Consumer<NewProductDiscountBean>() {
            @Override
            public void accept(@NonNull NewProductDiscountBean bean) throws Exception {
                if("0".equals(bean.getCode())){
                    mView.showDiscountList(bean.getData());
                }
            }
        }, new ThrowableConsumer());
        mRxManager.add(disposable);
    }
}